﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._08_桥接模式
{
    /// <summary>
    /// 顺丰快递
    /// </summary>
    public class SFExpress : ILogisticsCompany
    {
        /// <summary>
        /// 计算运单费用
        /// </summary>
        /// <param name="weight"></param>
        /// <param name="volume"></param>
        /// <returns></returns>
        public decimal CalculateFreight(decimal weight, decimal volume)
        {
            Console.WriteLine("计算运单费用》。。");
            return Math.Max(weight * 8, volume * 150);
        }

        /// <summary>
        /// 取消运单
        /// </summary>
        /// <param name="waybillNumber"></param>
        public void CancelShipment(string waybillNumber)
        {
            Console.WriteLine($"顺丰取消运单：{waybillNumber}");
        }

        /// <summary>
        /// 创建运单
        /// </summary>
        /// <returns></returns>
        public string CreateWaybill()
        {
            string waybill = $"SF{DateTime.Now:yyyyMMddHHmmss}";
            Console.WriteLine($"顺丰创建运单：{waybill}");
            return waybill;
        }

        public string GetCompanyName() => "顺丰速运";

        /// <summary>
        /// 跟踪运单
        /// </summary>
        /// <param name="waybillNumber"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public string TrackShipment(string waybillNumber)
        {
            return new Random().Next(100) > 10 ? "已到达北京转运中心" : "运输中";
        }
    }
}
